<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    var tupleSameProduct = function (nums) {
      const len = nums.length
      if (len < 4) return 0
      let map = new Map(), res = 0
      for (let i = 0; i < len; i++) {
        for (let j = i + 1; j < len; j++) {
          const x = nums[i] * nums[j]
          map.set(x, map.has(x) ? map.get(x) + 1 : 1)
        }
      }
      for (const [, v] of map) {
        if (v > 1) {
          res += v * (v - 1) >>> 1
        }
      }
      return res * 8
    };
    console.log(tupleSameProduct([1, 2, 4, 5, 10]));
  </script>
</body>

</html>